import QtQuick 2.4
import QtQuick.Controls 2.2

Rectangle {
    id: launch
    width: 400
    height: 400
    color: "#acdcaf"

    SDGUI {
        id: sdgui
        visible: false
        objectName: "objsdui"
        anchors.fill: parent
    }

    SPGUI {
        id: spgui
        visible: false
        objectName: "objspui"
        anchors.fill: parent

    }

    Item {
        id: item1
        x: 42
        y: 127
        width: 340
        height: 150
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter

        Button {
            id: btnsd
            x: 0
            y: 40
            width: 150
            height: 150
            text: qsTr("SD")
            anchors.verticalCenter: parent.verticalCenter
            font.bold: true
            font.pointSize: 20
        }

        Button {
            id: btnsp
            x: 190
            y: 44
            width: 150
            height: 150
            text: qsTr("SP")
            anchors.verticalCenter: parent.verticalCenter
            font.bold: true
            font.pointSize: 20
        }
    }


    Connections {
        target: btnsd
        onClicked: {
            launch.state = "offlinemap"
        }
    }


    Button {
        id: btnhome
        x: 0
        y: 298
        width: 100
        height: 100
        anchors.bottom: parent.bottom
        text: qsTr("Home")
        visible: false
        anchors.bottomMargin: 0
    }


    Connections {
        target: btnhome
        onClicked: launch.state = ""
    }


    Connections {
        target: btnsp
        onClicked: launch.state = "statespui"
    }

    states: [
        State {
            name: "offlinemap"

            PropertyChanges {
                target: item1
                visible: false
            }

            PropertyChanges {
                target: btnhome
                x: 1
                y: 298
                anchors.bottomMargin: 2
                visible: true
            }

            PropertyChanges {
                target: sdgui
                visible: true
            }

            PropertyChanges {
                target: spgui
                visible: false
            }
        },
        State {
            name: "statespui"
            PropertyChanges {
                target: item1
                visible: false
            }

            PropertyChanges {
                target: btnhome
                visible: true
            }

            PropertyChanges {
                target: sdgui
                visible: false
            }

            PropertyChanges {
                target: spgui
                visible: true
            }
        }
    ]
}
